package edu.wtbu.cs.androiddemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import edu.wtbu.cs.androiddemo.R;
import edu.wtbu.cs.androiddemo.activity.jump.ActivityLifeCycleDemoActivity;

import edu.wtbu.cs.androiddemo.activity.jump.FragmentDemoActivity;
import edu.wtbu.cs.androiddemo.activity.jump.IntentDemoActivity;


/**
 * 页面跳转和切换
 */
public class PageJumpAndSwitchSampleActivity extends AppCompatActivity {

    public static String logTag = PageJumpAndSwitchSampleActivity.class.getName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_page_jump_and_switch_sample);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }

    public void clickFragmentButton(View view){
        Log.i(logTag,"clickFragmentButton");
        Intent intent = new Intent(PageJumpAndSwitchSampleActivity.this, FragmentDemoActivity.class);
        startActivity(intent);
    }

    public void clickIntentDemoButton(View view){
        Log.i(logTag,"clickIntentDemoButton");
        Intent intent = new Intent(PageJumpAndSwitchSampleActivity.this, IntentDemoActivity.class);
        startActivity(intent);
    }

    public void clickActivityLifeCycleButton(View view){
        Log.i(logTag,"clickActivityLifeCycleButton");
        Intent intent = new Intent(PageJumpAndSwitchSampleActivity.this,ActivityLifeCycleDemoActivity.class);
        startActivity(intent);
    }

    public void clickActivityButton(View view){
        Log.i(logTag,"clickActivityButton");
        Intent intent = new Intent(PageJumpAndSwitchSampleActivity.this,LoginActivity.class);
        startActivity(intent);
    }
}